import React, { Component } from 'react';
import './style.css'
// import { Redirect } from 'react-router-dom';
import ReactEcharts from 'echarts-for-react';
import 'echarts-wordcloud'
import request from '../../request';
// import ReactEcharts from 'echarts-for-react';


class KeyWord extends Component{

  componentDidMount() {
    request.get('/api/isLogin').then(res => {
      const data: boolean = res.data;
      if (!data) {
        this.setState({
          isLogin: false,
          loading: false
        });
      } else {
        this.setState({
          loading: false
        });
      }
    });

    request.get('/api/showWenCaiData').then(res => {
      const data = res.data;
      if (data) {
        this.setState({ data });
      }
    });
  }

  option = {
    title: {
        text: '词云',//标题
        x: 'center',
        textStyle: {
            fontSize: 23
        }
 
    },
    backgroundColor: '#F7F7F7',
    tooltip: {
        show: true
    },
    series: [{
        name: '热点分析',//数据提示窗标题
        type: 'wordCloud',
        sizeRange: [6, 66],//画布范围，如果设置太大会出现少词（溢出屏幕）
        rotationRange: [-45, 90],//数据翻转范围
        //shape: 'circle',
        textPadding: 0,
        rotationStep: 45,
        gridSize: 8,
        shape: 'pentagon',
        width: '100%',
        height: '100%',
        autoSize: {
            enable: true,
            minSize: 6
        },
        textStyle: {
            normal: {
                color: function() {
                    return 'rgb(' + [
                        Math.round(Math.random() * 160),
                        Math.round(Math.random() * 160),
                        Math.round(Math.random() * 160)
                    ].join(',') + ')';
                }
            },
            emphasis: {
                shadowBlur: 10,
                shadowColor: '#333'
            }
        },
        data: [{"name":"男神","value":2.64},
        {"name":"好身材","value":4.03},
        {"name":"校草","value":24.95},
        {"name":"酷","value":4.04},
        {"name":"时尚","value":5.27},
        {"name":"阳光活力","value":5.80},
        {"name":"初恋","value":3.09},
        {"name":"英俊潇洒","value":24.71},
        {"name":"霸气","value":6.33},
        {"name":"腼腆","value":2.55},
        {"name":"蠢萌","value":3.88},
        {"name":"青春","value":8.04},
        {"name":"网红","value":5.87},
        {"name":"萌","value":6.97},
        {"name":"认真","value":2.53},
        {"name":"古典","value":2.49},
        {"name":"温柔","value":3.91},
        {"name":"有个性","value":3.25},
        {"name":"可爱","value":9.93},
        {"name":"幽默诙谐","value":3.65}]
    }]
  }

  render() {
    return (
      <div>
        <ReactEcharts option={this.option} />
      </div>
    )
  }
}

export default KeyWord
